<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<script type="text/javascript">
	$(document).ready(function(){
		//添加排序特征
		$.injectOrderFeature('searchForm','${param.orderName}','${param.order}');
	});
	$('.tipMe').tooltip({'placement':'top'});
	function search(form) {
		$(form).appendPagerParaStr();
		return true;
	}
	
	/**
	 * 根据Id停用用户，假删
	 */
	function deleteById(userCode,userName){
		window.parent.ui.confirm('确认停用: '+userName+'('+userCode+') ?',function(){
			 $.ajax({
				   type: "POST",
				   dataType:"json",
				   cache: false,
				   url: _ctx + "/pub/sysmgr/usermgr/disable_user.do",
				   data: {id:userCode},
				   success: function(resp){
					   if(resp.status == '1'){
						   window.parent.ui.msg(resp.msg, 1);
						   ui.go(_ctx + '/pub/sysmgr/usermgr/user_list.do');
					   }else{
						   window.parent.ui.msg(resp.msg, 0);
					   }
				   },
				   error:function(){
					   window.parent.ui.msg('信息加载错误', 0);
				   }
			}); 
		});	
	}

	/**
	 * 根据Id启用用户
	 */
	function recoverById(userCode,userName){
		window.parent.ui.confirm('确认启用: '+userName+'('+userCode+') ?',function(){
			 $.ajax({
				   type: "POST",
				   dataType:"json",
				   cache: false,
				   url: _ctx + "/pub/sysmgr/usermgr/enable_user.do",
				   data: {id:userCode},
				   success: function(resp){
					   if(resp.status == '1'){
						   window.parent.ui.msg(resp.msg, 1);
						   ui.go(_ctx + '/pub/sysmgr/usermgr/user_list.do');
					   }else{
						   window.parent.ui.msg(resp.msg, 0);
					   }
				   },
				   error:function(){
					   window.parent.ui.msg('信息加载错误', 0);
				   }
			}); 
		});	
	}
</script>
</head>
<style type="text/css">
th{word-break: keep-all;white-space:nowrap;}
</style>
<body>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<div class="main-content" style="margin-left: 0px;">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb" style="margin-left: 4px;">
						<li><i class="icon-home home-icon"></i>系统管理
						</li>
						<li>用户管理
						</li>
						<li class="active">用户列表</li>
					</ul>
				</div>
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div class="widget-box">
								<div class="widget-header widget-header-flat">
									<h5 class="smaller lighter">
										<i class="icon-list"> &nbsp;用户列表</i> &nbsp;
									</h5>
									<div class="widget-toolbar no-border">
										   <a class="btn btn-primary btn-xs" href="${ctx}/pub/sysmgr/usermgr/user_add.do" ><i class="icon-plus-sign icon-on-right"></i> 添加用户&nbsp;&nbsp;</a>
										   <a href="#" data-action="collapse">
											<i class="icon-chevron-up"></i>
										</a>
									</div>
								</div>
								<div class="widget-body">
									<div class="widget-main">
										<form id="searchForm" class="form-search"
											action="${ctx}/pub/sysmgr/usermgr/user_list.do"
											method="post" onsubmit="return search(this)">
											<div class="row mg-top12">
												<div class="col-xs-4">
													<div class="input-group">
														<span class="input-group-addon">用&nbsp;户&nbsp;名</span> <input
															class="form-control" type="text" name="userName" id="userName"
															value="${param.userName}" />
													</div>
												</div>
												<div class="col-xs-4">
													<div class="input-group">
														<span class="input-group-addon">电子邮箱</span> <input
															class="form-control" type="text" name="email" id="email"
															value="${param.email}" />
													</div>
												</div>
												<div class="col-xs-4">
													<div class="input-group">
														<span class="input-group-btn">
															<button type="submit" class="btn btn-purple btn-sm">
																<i class="icon-search icon-on-right bigger-110"></i> 查询
															</button>&nbsp;&nbsp; </span>
													</div>
												</div>
											</div>
										</form>
									</div>
								</div>
							</div>

							<div class="hr hr12 hr-dotted"></div>

							<div id="optDiv">
								<div class="table-responsive">
									<table id="sample-table-1"
										class="table table-striped table-bordered table-hover">
										<thead>
											<tr>
												<th class="center">
													<label>
													<input type="checkbox" class="ace" id="checkedAll"/>
													<span class="lbl"></span>
													</label>
												</th>
												<th _orderCloumnName="userName">用户名</th>
												<th>是否管理员</th>
												<th _orderCloumnName="email">电子邮箱</th>
												<th _orderCloumnName="tel">电话号码</th>
												<th _orderCloumnName="status">状态</th>
												<th _orderCloumnName="modified">最后修改时间</th>
												<th>备注</th>
												<th>操作</th>
											</tr>
										</thead>

										<tbody>
											<c:forEach var="vo" items="${users}">
												<tr>
													<td class="center">
														<label>
														<input type="checkbox" class="ace" value="${vo.id}"/>
														<span class="lbl"></span>
														</label>
													</td>
													<td >${vo.userName}&nbsp;</td>
													<td>${cm:yesNoStr(vo.admin)}&nbsp;</td>
													<td >${vo.email}&nbsp;</td>
													<td >${vo.tel}&nbsp;</td>
													<td>${cm:ctname('entity_status',vo.status)}&nbsp;</td>
													<td><fmt:formatDate value="${vo.modified}" pattern="yyyy-MM-dd HH:mm:ss" />&nbsp;</td>
													<td ><span class="tipMe" title="${vo.remark}">${cm:lmitStrPx(vo.remark,200)}&nbsp;</span></td>
													<td>
														<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
															<a class="blue" href="${ctx}/pub/sysmgr/usermgr/get_user.do?id=${vo.id}" title="查看">
																<i class="icon-zoom-in bigger-130"></i>
															</a>
															<c:if test="${'9' != vo.status }">
																<c:if test="${'1' == vo.status}">
																<a class="purple" href="${ctx}/pub/sysmgr/usermgr/user_role_choose_role.do?userId=${vo.id}" title="配置角色">
																	<i class="icon-legal bigger-130"></i>
																</a>
																
																<a class="black" href="${ctx}/usermgr/user_node_mgr.do?id=${vo.id}" title="用户节点权限配置">
																	<i class="icon-book bigger-130"></i>
																</a>
																
																<a class="green" href="${ctx}/pub/sysmgr/usermgr/user_update.do?id=${vo.id}" title="修改用户信息">
																	<i class="icon-pencil bigger-130"></i>
																</a>
																<%-- <a class="green" href="javascript:void(0);" onclick="userPasswordReset('${vo.id}')" title="重置密码">
																	<i class="icon-key bigger-130"></i>
																</a> --%>
																<a class="red" href="javascript:void(0)" onclick="deleteById('${vo.id}','${vo.userName}');" title="停用">
																	<i class="icon-lock bigger-130"></i>
																</a>
																</c:if>
																<c:if test="${'0' == vo.status}">
																<a class="green" href="javascript:void(0)" onclick="recoverById('${vo.id}','${vo.userName}');" title="启用">
																	<i class="icon-unlock bigger-130"></i>
																</a>
																</c:if>
															</c:if>
															<%-- <a class="red" href="javascript:void(0);" onclick="userInfoDel('${vo.id}','${vo.userName}')" title="删除">
																<i class="icon-trash bigger-130"></i>
															</a> --%>
														</div>
													</td>
												</tr>
											</c:forEach>
										</tbody>
									</table>

									<jsp:include page="/WEB-INF/view/common/pg.jsp">
										<jsp:param value="${ctx}/pub/sysmgr/usermgr/user_list.do"
											name="url" />
										<jsp:param value="${_total}" name="total" />
										<jsp:param value="${_urlpara}" name="urlpara" />
									</jsp:include>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
